﻿@using Sharp.DataTransferObject
@using Sharp.Infrastructure.WebApiClient
@using Sharp.ServiceContracts
@using Sharp.WebBooter.Areas.Platform.Controllers
@if (ViewBag.IsPjaxRequest == false)
{
    Layout = "~/Areas/Platform/Views/Shared/__Layout.cshtml";

}
@{
    List<OrgIndexViewModel> newOrgList = new List<OrgIndexViewModel>();
    IEnumerable<OrgDTO> list;

    using (var proxy = new WebApiClientServiceProxy<IEnterpriseService>())
    {
        list = proxy.Channel.GetOrgs().Result;
    }

    OrgController.Build(list, newOrgList, null);
}
<script>
    function treeclick(obj, orgId) {

        var $Searchform = $(obj).parents(".row").find(".SearchArea form");
  
        var orgIds = new Array();

        var $c = $Searchform.find("input[name='OrgId']");
        if ($c.length === 0) {
            $c = $Searchform.find("input[data-original='OrgId']");
        }
        $c.val("");
        $Searchform.find("input[clone='1']").remove();
        $("#orgTreeDataList .checkColumn input[name='cellCheckbox']:checked").each(function (index,item) {
            if (item.checked) {
                if (index === 0) {
                    $c.val(item.value);
                } else {
                    $Searchform.append($c.clone().attr("clone",1).val(item.value));
                }
                orgIds.push(item.value);
            }
        });

        $Searchform.find(".btn-success").click();
    }
</script>
<section class="content">
    <div class="row">
        <div class="col-sm-3">
            <div class="box box-solid">
                <div class="box-header with-border">
                    <h3 class="box-title">组织</h3>

                    <div class="box-tools">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse">
                            <i class="fa fa-minus"></i>

                        </button>
                    </div>
                </div>
                <div class="box-body no-padding" style="height: auto;min-height:100%;">
                    
                        <table id="orgTreeDataList" class="table table-bordered table-condensed table-striped table-hover">
                            <thead>
                                <tr>
                                    <th style="width:43px;" class="center"></th>
                                    <th style="width:240px;">名称</th>
                                </tr>
                            </thead>
                            <tbody>
                                @{
                                    foreach (var item in newOrgList)
                                    {
                                        <tr class="@item.Itemclass">
                                            <td style="width:43px;padding:1px;" class="center checkColumn"><label><input type="checkbox" name="cellCheckbox" value="@item.Id" onclick="treeclick(this, '@item.Id')" /><i></i></label></td>
                                            <td style="padding:1px;">
                                                @item.Title</td>
                                        </tr>
                                    }
                                }
                            </tbody>
                        </table>
                        <script>
                            $('#orgTreeDataList').treegrid({
                                treeColumn: 1,
                                expandAll: false  //是否全部展开
                            });
                        </script>
                    
                </div>
            </div>

        </div>
        <!-- /.col -->
        <div class="col-sm-9 no-padding">
            @RenderSection("tabContent", required: true)
        </div>
    </div>
</section>